package com.example.armmvvm.ui.constraint.normalfallview

import android.view.View
import android.view.ViewGroup
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.LifecycleOwner
import com.example.armmvvm.R
import com.example.armmvvm.databinding.LayoutBottomBehaviorTestBinding
import com.example.armmvvm.ui.fallview.AnchorFallView
import com.example.armmvvm.ui.fallview.AnchorFallViewSetting
import com.example.armmvvm.ui.fallview.FallViewMode

/**
 *  author : yanghaozhang
 *  date : 2022/10/18 17:48
 *  description :
 */
class NormalOneStateFallView(lifecycleOwner: LifecycleOwner, viewContainer: ViewGroup) :
    AnchorFallView(lifecycleOwner, viewContainer, R.layout.layout_bottom_behavior_test) {

    override fun updateView(view: View) {
        LayoutBottomBehaviorTestBinding.bind(view).apply {
            scrollView.updateLayoutParams {
                height = ViewGroup.LayoutParams.WRAP_CONTENT
            }
            blankView.updateLayoutParams {
                height = ViewGroup.LayoutParams.WRAP_CONTENT
            }
            tvContent.text = "NormalOneStateFallView"
            tvContent.setOnClickListener {
                NormalTwoStateFallView(lifecycleOwner, viewContainer).show()
            }
        }
    }

    override fun bottomFallViewSetting(view: View): AnchorFallViewSetting? {
        return AnchorFallViewSetting(view).apply {
            mode = FallViewMode.ONE_STATE
        }
    }
}